import React from 'react'

import { useLocation } from "react-router-dom";
import { qs } from "url-parse";

export default function Detail2() {
  const { search } = useLocation();
  console.log(search);
  //获取到的search是urlencoded编码字符串(例如: ?name=ACE&age=22)，需要借助 url-parse 里面的 qs.parse 解析参数成对象
  const searchs = qs.parse(search);
  console.log(searchs);
  return (
    <div>
      <h2>Detail2 </h2>
      <h2>姓名：{searchs.name} / 年龄：{searchs.age}</h2>
    </div>
  )
}
